set nocompatible

call plug#begin()

" A collection of language packs for Vim.
Plug 'sheerun/vim-polyglot'
" colors inspired by the excellent One Dark syntax theme for the Atom text editor.
Plug 'joshdick/onedark.vim'
" Lean & mean status/tabline for vim that's light as air.
Plug 'vim-airline/vim-airline'
" Add icons to your plugins
Plug 'ryanoasis/vim-devicons'
" The NERDTree is a file system explorer for the Vim editor.
Plug 'preservim/nerdtree'
" A plugin of NERDTree showing git status flags.
Plug 'Xuyuanp/nerdtree-git-plugin'
" NERD Commenter
Plug 'preservim/nerdcommenter'
" Full path fuzzy file, buffer, mru, tag, ... finder for Vim.
Plug 'ctrlpvim/ctrlp.vim'
" Fugitive is the premier Vim plugin for Git
Plug 'tpope/vim-fugitive'
Plug 'ton/vim-alternate'

call plug#end()

"Very hate vi backspace mode
set backspace=indent,eol,start

" Encodings
set encoding=utf-8
set termencoding=utf-8
set fileencodings=utf-8,ucs-bom,gbk,gb18030,gb2312,cp930,korea

" Menu garbled code
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim

" Do wrap
set nowrap

" Use mouse
set mouse=a

" wildmenu
if has("wildmenu")
	set wildmenu
	set wildmode=longest,list
endif

" Show the cursor position all the time
set ruler

" Display incomplete commands
set showcmd

" Display current edit mode
set showmode

" Do incremental searching
set incsearch

" Highlight search
set hlsearch

" Show line number 
set number

" Do not generate backup file
set nobackup

" Show match symbal
set showmatch

" I hate tab instead by spaces
set noexpandtab

" Set tab width
set tabstop=4

" Set backspace width
set softtabstop=4

" Set << and >> command to move width
set shiftwidth=4

" C style indent
set cindent 

colorscheme onedark

" Enable syntax except diff mode
if &diff
	syntax off
else
	syntax on
endif

" Vimdiff off syntax
if &diff
	syntax off
endif

" Enable to highlight doxygen tags
let g:load_doxygen_syntax=1

" Highlight current line
set cursorline

" Enable loading indent file for filetype
filetype indent plugin on

" Enable plugins
filetype plugin on
" enable the menu
set completeopt=menuone,longest

" enable modeline
set modeline

" filetype
autocmd BufNewFile,BufRead *.psql		set filetype=psql
autocmd BufNewFile,BufRead *.postgresql set filetype=postgresql
autocmd BufNewFile,BufRead *.proto		set filetype=proto
autocmd BufNewFile,BufRead *.md			set filetype=markdown
autocmd BufNewFile,BufRead *.nut		set filetype=squirrel

" Search files
let &path.="/usr/include,/usr/local/include"


" Dictionaries
set dict+=~/.vim/dict/words_c
set dict+=~/.vim/dict/words_cpp
set dict+=~/.vim/dict/words_macro

" <<Airline>>
  if !exists('g:airline_symbols')
    let g:airline_symbols = {}
  endif

  " unicode symbols
  let g:airline_left_sep = '▶'
  let g:airline_right_sep = '◀'
  let g:airline_symbols.colnr = 'Col:'
  let g:airline_symbols.crypt = '🔒'
  let g:airline_symbols.linenr = 'Row:'
  let g:airline_symbols.maxlinenr = ' '
  let g:airline_symbols.branch = '⎇'
  let g:airline_symbols.paste = 'Þ'
  let g:airline_symbols.spell = 'Ꞩ'
  let g:airline_symbols.notexists = 'Ɇ'
  let g:airline_symbols.whitespace = 'Ξ'

nnoremap <C-t> :NERDTreeToggle<CR>
nnoremap <C-f> :NERDTreeFind<CR>

" <<NERD Commentor>>
" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1
